package com.jianbing.util.datacheck;

import com.jianbing.dao.MongoDBDao;
import com.jianbing.entity.datacheck.DataCheckRule;
import com.jianbing.util.ColletionUtils;
import com.jianbing.util.TableUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by hantixiang on 2016/12/21.
 */
public class DataCheckHelper {
	public static String containAsterisk = "containAsterisk";
	public static String containChinese = "containChinese";
	public static String containSpace = "containSpace";
	public static String containSpecialChar = "containSpecialChar";
	public static String len = "len";
	public static String letter = "letter";
	public static String nuberAndLetterAnd_ = "nuberAndLetterAnd_";
	public static String numberAndLetter = "numberAndLetter";
	public static String numberOrLetter = "numberOrLetter";
	public static String notChinese = "notChinese";
	public static String chinese = "chinese";
	public static String IDCardNumber = "IDCardNumber";
	public static String date = "date";
	public static String dateAfter1900year = "dateAfter1900year";
	public static String dateBeforeNow = "dateBeforeNow";
	public static String yyyyMMDate = "yyyyMMDate";
	public static String isNumber = "isNumber";
	public static String positiveNumber = "positiveNumber";
	public static String negativeNumber = "negativeNumber";
	public static String decimal = "decimal";
	public static String integer = "integer";
	public static String baseEqualPerPayPlusComPay = "baseEqualPerPayPlusComPay";
	public static String baseLessDepositeBase = "baseLessDepositeBase";
	public static String balanceEqualsDetailBalanceSum = "balanceEqualsDetailBalanceSum";
	public static String email = "email";

	public static final String NO_CHECK = "未校验", CHECK_PASS = "是", CHECK_FAIL = "否";

	public static Map<String,String> getNewDataCheckRule() {
        List<DataCheckRule> list = MongoDBDao.queryForList(TableUtils.getTableName(DataCheckRule.class), null, DataCheckRule.class);
        if (ColletionUtils.isEmpty(list)) {
            return null;
        }
        Map<String,String> map = new HashMap<String,String>();
        for (DataCheckRule rule : list) {
            map.put(rule.getExpr(), rule.getName());
        }
        return map;
    }
}
